<body>
<p>Test that destroying a document doesn't cause a crash when executing MessageChannel constructor saved from its Window object.</p>
<pre id=log></pre>
<script src="../../resources/gc.js"></script>
<script>

function log(message)
{
    document.getElementById("log").innerHTML += message + "<br>";
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

var constructor;

function test()
{
    constructor = window.frames[0].MessageChannel;

    var frameElement = document.getElementsByTagName("iframe")[0];
    frameElement.parentNode.removeChild(frameElement);
    frameElement = null;

    gc();
    setTimeout(test2, 10);
}

function test2()
{
    gc();
    try {
        new constructor;
    } catch (ex) {
    }

    log("Didn't crash: SUCCESS");

    if (window.testRunner)
        testRunner.notifyDone();
}

</script>
<iframe src="resources/message-port-iframe.html" onload="test()"></iframe>
</body>
